package icu.twtool.entity

import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

/**
 * @author Wen
 * @since 2022-11-08
 */
class BinaryEquationBaseTest {

    private val binaryEquationBase = BinaryEquationBase(100)

    @Test
    fun getAdditionEquation() {
        val equation = binaryEquationBase.getAdditionEquation()
        assert(equation.first in 0..100)
        assert(equation.operation == '+')
        assert(equation.second in 0..100)
    }

    @Test
    fun getSubtractionEquation() {
        val equation = binaryEquationBase.getSubtractionEquation()
        assert(equation.first in 0..100)
        assert(equation.operation == '-')
        assert(equation.second in 0..100)
    }

    @Test
    fun getEquation() {

        val equation = binaryEquationBase.getEquation()
        assert(equation.first in 0..100)
        assert(equation.operation == '+' || equation.operation == '-')
        assert(equation.second in 0..100)
    }

    @Test
    fun get() {
        assertEquals(binaryEquationBase.get(0, 0), AdditionBinaryEquation(0, 0))
        assertEquals(binaryEquationBase.get(0, 100), AdditionBinaryEquation(0, 100))
        assertEquals(binaryEquationBase.get(0, 101), SubtractionBinaryEquation(0, 0))

        assertEquals(binaryEquationBase.get(100, 0), AdditionBinaryEquation(100, 0))
        assertEquals(binaryEquationBase.get(100, 1), SubtractionBinaryEquation(100, 100))
        assertEquals(binaryEquationBase.get(100, 101), SubtractionBinaryEquation(100, 0))
    }
}